import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import ProductItem from '../../components/ProductItem/ProductItem'
import BottomLine from '../../components/BottomLine/BottomLine'

//引入银行图片资源
import b1 from '../../images/bank/2.png'
import b2 from '../../images/bank/0.png'
import b3 from '../../images/bank/1.png'
import b4 from '../../images/bank/3.png'
import b5 from '../../images/bank/4.png'
//引入nothing图片
import nothing from '../../images/err/nothing.png'

import './chooseProduct.scss'

export default class Chooseproduct extends Component {

  config = {
    navigationBarTitleText: '选择产品'
  }

  state={
    products:[]
  }

  componentWillMount () {
    let {products} =this.state
    let {id}= this.$router.params  //对应需求的id
    console.log(id)
    Taro.request({
      url:"http://101.37.65.67/loudi-poc/demand/"+id+"/list",
      method:"GET",
      success:(res)=>{
        products=res.data.data
        this.setState({
          products
        })
      }
    })
    
  }

  componentDidMount () { 
    
  }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

  productTypes=['','抵押',"质押","信保","一般保证","信用"]

  render () {
    return (
      <View className='chooseProduct'>
        <View className='products'>
          {
            this.state.products.map((p,index)=>{
              return <ProductItem key={p.id} url={'/pages/applySuccess/applySuccess?pid='+p.id+"&nid="+this.$router.params.id} openType="redirect"/*关闭当前界面，并跳转到成功界面*/ src={b1} name={p.productName} productType={this.productTypes[p.guaranteeMode]+"基金"} rate={p.loanRateLower+"%~"+p.loanRateUpper+"%"} time={p.loanTermLower+'~'+p.loanTermUpper+'个月'} rateType='参考利率'></ProductItem>
            })
          }
          {/* <ProductItem url='/pages/applySuccess/applySuccess' openType="redirect" 关闭当前界面，并跳转到成功界面 src={b1} name="农村信保贷" productType="信保基金" rate="4.35%~5.66%" time='6~12个月' rateType='参考利率'></ProductItem> */}
          {/* <ProductItem url='/pages/applySuccess/applySuccess' openType="redirect" 关闭当前界面，并跳转到成功界面 src={b2} name="农村信保贷" productType="信保基金" rate="4.35%~5.66%" time='6~12个月' rateType='参考利率'></ProductItem> */}
          {/* <ProductItem url='/pages/applySuccess/applySuccess' openType="redirect" 关闭当前界面，并跳转到成功界面 src={b3} name="农村信保贷" productType="信保基金" rate="4.35%~5.66%" time='6~12个月' rateType='参考利率'></ProductItem> */}
          {/* <ProductItem url='/pages/applySuccess/applySuccess' openType="redirect" 关闭当前界面，并跳转到成功界面 src={b4} name="农村信保贷" productType="信保基金" rate="4.35%~5.66%" time='6~12个月' rateType='参考利率'></ProductItem> */}
          {/* <ProductItem url='/pages/applySuccess/applySuccess' openType="redirect" 关闭当前界面，并跳转到成功界面 src={b1} name="农村信保贷" productType="信保基金" rate="4.35%~5.66%" time='6~12个月' rateType='参考利率'></ProductItem> */}
          {/* <ProductItem url='/pages/applySuccess/applySuccess' openType="redirect" 关闭当前界面，并跳转到成功界面 src={b2} name="农村信保贷" productType="信保基金" rate="4.35%~5.66%" time='6~12个月' rateType='参考利率'></ProductItem> */}
          {/* <ProductItem url='/pages/applySuccess/applySuccess' openType="redirect" 关闭当前界面，并跳转到成功界面 src={b3} name="农村信保贷" productType="信保基金" rate="4.35%~5.66%" time='6~12个月' rateType='参考利率'></ProductItem> */}
          {/* <ProductItem url='/pages/applySuccess/applySuccess' openType="redirect" 关闭当前界面，并跳转到成功界面 src={b4} name="农村信保贷" productType="信保基金" rate="4.35%~5.66%" time='6~12个月' rateType='参考利率'></ProductItem> */}
          {/* <ProductItem url='/pages/applySuccess/applySuccess' openType="redirect" 关闭当前界面，并跳转到成功界面 src={b1} name="农村信保贷" productType="信保基金" rate="4.35%~5.66%" time='6~12个月' rateType='参考利率'></ProductItem> */}
          {/* <ProductItem url='/pages/applySuccess/applySuccess' openType="redirect" 关闭当前界面，并跳转到成功界面 src={b2} name="农村信保贷" productType="信保基金" rate="4.35%~5.66%" time='6~12个月' rateType='参考利率'></ProductItem> */}
          <BottomLine></BottomLine>
        </View>
        <View className='nothing'>
          <Image mode='widthFix' src={nothing}></Image>
          <View>
            暂无找到相匹配的产品，系统已将你的需求发布至需求池，请耐心等待
          </View>
          <Navigator url='/pages/product/product' className='toProductPage' open-type='switchTab'>前往产品列表选择</Navigator>
        </View>
        </View>
    )
  }
}
